/**
 * 
 */
package com.dragon.modules.yuegou.client.wechat.response;

import com.dragon.common.exception.DragonException;
import com.dragon.modules.yuegou.enums.code.LiveCode;
import com.dragon.modules.yuegou.enums.code.LiveUtils;

import java.io.Serializable;

/**
 * @author 上传媒体文件响应
 *
 */
public class MediaUploadResponse implements Serializable{
	private static final long serialVersionUID = -6065118260219736417L;

	// 错误码
	private Integer errcode;

	// 错误信息
	private String errmsg;
	
	//媒体文件类型，分别有图片（image）、语音（voice）、视频（video）和缩略图（thumb，主要用于视频与音乐格式的缩略图）
	private String type;
	
	//媒体文件上传后，获取标识
	private String mediaId;
	
	//媒体文件上传时间戳
	private Long createdAt;

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getMediaId() {
		return mediaId;
	}

	public void setMediaId(String mediaId) {
		this.mediaId = mediaId;
	}

	public Long getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(Long createdAt) {
		this.createdAt = createdAt;
	}
	
	public Integer getErrcode() {
		return errcode;
	}

	public void setErrcode(Integer errcode) {
		this.errcode = errcode;
	}

	public String getErrmsg() {
		return errmsg;
	}

	public void setErrmsg(String errmsg) {
		this.errmsg = errmsg;
	}

	// 响应较验
	public void check() {
		if (null != errcode && errcode.intValue() != 0) {
			LiveCode liveCode = LiveUtils.getLiveCode(errcode);
			if (liveCode == null) {
				throw new DragonException(LiveCode.LIVE_ERROR.getCode(),String.format(LiveCode.LIVE_ERROR.getMessage(),errmsg));
			}else {
				throw new DragonException(liveCode);
			}

		}
	}
	
}
